<?php
/**
 * Created by PhpStorm.
 * User: sunwenxu
 * Date: 2019/6/20
 * Time: 12:48
 */

namespace app\common\lib;


use Predis\Client;

class Redis
{
    public $redis = "";
    private static ?Redis $instance = null;

    public static function getInstance(): ?Redis
    {
        if (self::$instance === null) {
            self::$instance = new self();
        }
        return self::$instance;
    }

    final private function __construct()
    {
        $server = array(
            'scheme' => 'tcp',
            'host' => env("redis.host", '192.168.1.202'),
            'port' => env("redis.port", 6379),
           // 'persistent' => true,
        );
        $this->redis = new Client($server);
        $this->redis->auth(env("redis.password", "maker123"));
    }


    final public function __clone()
    {
        // TODO: Implement __clone() method.
    }
}